/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sellcar;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 *
 * @author Fabio Valenzuela
 */
public class Cadastro_VendedorDAO {
    
    private Connection connection;

    public Cadastro_VendedorDAO() {
        this.connection = new ConnectionFactory().getConnection();
    }
    public void adiciona (Vendedor vendedor){
        String sql = "insert into tb_cadastro_vendedor" + "(NOME,RG,CPF,DT_NASC,TEL_1,TEL_2,TEL_CEL_1,TEL_CEL_2,EMAIL,ENDERECO,BAIRRO,CIDADE,COMPL,CEP,UF)" + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        
        try{
            PreparedStatement stmt = connection.prepareStatement(sql);
            
            stmt.setString(1, vendedor.getNome());
            stmt.setString(2, vendedor.getRg());
            stmt.setString(3, vendedor.getCpf());
            stmt.setString(4, vendedor.getDtnasc());
            stmt.setString(5, vendedor.getTel1());
            stmt.setString(6, vendedor.getTel2());
            stmt.setString(7, vendedor.getCel1());
            stmt.setString(8, vendedor.getCel2());
            stmt.setString(9, vendedor.getEmail());
            stmt.setString(10, vendedor.getEnd());
            stmt.setString(11, vendedor.getBairro());
            stmt.setString(12, vendedor.getCid());
            stmt.setString(13, vendedor.getComp());
            stmt.setString(14, vendedor.getCep());
            stmt.setString(15, vendedor.getUf());
            
            
            stmt.execute();
            stmt.close();
            connection.close();
        }catch(SQLException e ){
            throw new RuntimeException(e);
        }
    }
}
